package com.guomao.filter;

import jakarta.servlet.*;

import java.io.IOException;

public class MyFilterA implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

        System.out.println("MyFilterA init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException, ServletException {
        System.out.println("MyFilterA before");
//        System.out.println("MyFilterA doFilter");

//        如果有多个过滤器 一定要把请求对象和响应对象交给下一个过滤器
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("MyFilterA after");
    }

    @Override
    public void destroy() {
        System.out.println("MyFilterA destroy");
    }
}
